package edu.sctu;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "addUserServlet")
public class addUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        PrintWriter out=response.getWriter();
        out.println("<html>");
        out.println("<head><title></head></title>");
        out.println("<body>");
        out.println("<h1><a href=\"userList\">返回列表</a></h1>");
        out.println("</body>");
        out.println("</html>");
        out.close();
        AddDataBase addDataBase=new AddDataBase();
        addDataBase.setUsername(username);
        addDataBase.setPassword(password);
        addDataBase.addData();
    }
}
